package com.tourManagement.service.impl;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import com.tourManagement.entity.Route;
import com.tourManagement.service.RouteService;
import org.springframework.stereotype.Service;

import java.sql.SQLException;
import java.util.List;
@Service
public class RouteServiceImpl implements RouteService {
    //查询所有路线信息
    @Override
    public List<Route> getAllRoute() throws SQLException {
        return Db.use().findAll(Entity.create("t_route"),Route.class);
    }
    //插入路线信息
    @Override
    public int insertRoute(Route routeInfo) throws SQLException {
        return Db.use().insert(Entity.create("t_route").parseBean(routeInfo,true,false));
    }
    //删除路线信息
    @Override
    public int deleteRoute(int routeId) throws SQLException {
        return Db.use().execute("delete from t_user where name = ?",routeId);
        }
    //更新路线信息
    @Override
    public int updateRoute(Route routeInfo) throws SQLException {
        return Db.use().update(Entity.create("t_route").parseBean(routeInfo),
                Entity.create("t_route").set("routeId",routeInfo.getRouteId()));

    }

    @Override
    public int getRouteBy(Route route) throws SQLException {


        Db.use().findAll(Entity.create("t_route").parseBean(route, true, true));
        return 0;
    }


}
